package com.liaoban.app.ui.anchor;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.LinearLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.liaoban.app.R;
import com.liaoban.app.adapter.PhotoAdapter;
import com.liaoban.app.api.type.WuserImg;
import com.liaoban.app.api.type.request.GiftRequest;
import com.liaoban.app.biz.CommonBiz;
import com.liaoban.app.constants.Constant;
import com.liaoban.app.constants.ExtraParam;
import com.liaoban.app.ui.base.BaseListActivity;
import com.liaoban.app.util.CommonUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by ybc on 2018/7/30 0030.
 * 主播详情相册
 */
public class PhotoActivity extends BaseListActivity<WuserImg> {
    private String mWuserId;

    public static Intent newIntent(Context context, String wuserId) {
        Intent intent = new Intent(context, PhotoActivity.class);
        intent.putExtra(ExtraParam.ID, wuserId);
        return intent;
    }

    @Override
    public String getNewTitle() {
        return "相册";
    }

    @Override
    public BaseQuickAdapter getAdapter() {
        return new PhotoAdapter(null);
    }

    @Override
    public void itemChildClick(BaseQuickAdapter baseQuickAdapter, View view, int position) {

    }

    @Override
    public void itemClick(BaseQuickAdapter baseQuickAdapter, View view, int position) {
        WuserImg wuserImg = (WuserImg) baseQuickAdapter.getData().get(position);
        List<String> imgs = new ArrayList<>();
        imgs.add(CommonUtils.getFullPic(wuserImg.getImgSrc()));
        startActivity(ImgBannerActivity.newIntent(this, imgs, 0));
    }

    @Override
    public void getData() {
        GiftRequest giftRequest = new GiftRequest();
        giftRequest.setWuserId(mWuserId);
        giftRequest.setListrows(Constant.PAGE_SIZE + "");
        giftRequest.setPage(getPageIndex() + "");
        startTask(CommonBiz.getInstance().wuserImgList(giftRequest), listBaseResponse -> {
            doSuc(listBaseResponse.data, listBaseResponse.totalPageCount);
        });
    }

    @Override
    protected void setRecyclerView(RecyclerView recyclerView) {
        GridLayoutManager manager = new GridLayoutManager(this, 2);
        recyclerView.setLayoutManager(manager);
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        mWuserId = getIntent().getStringExtra(ExtraParam.ID);
        super.initView(savedInstanceState);
        int viewMarginXsmall = (int) getResources().getDimension(R.dimen.view_margin_xsmall);
        swipeLayout.setPadding(viewMarginXsmall, 0, viewMarginXsmall, 0);
    }
}
